import request from '@/utils/request.js'

//增
const returnUrl = arr=> arr.filter(val=>val).join('/')
/**
 *  moduleName模块名称 比如 systemApi userApi
 * type 子模块名称 如：user  log等
 *  name 接口路径名称
 * 
 */
export function add(data,type,moduleName,name){
  const url = returnUrl([moduleName,type,name]) 
  return request({
    url,
    method:'post',
    data
  })
}
//删
export function deleteIds(data,type,moduleName,name){
  const url = returnUrl([moduleName,type,name]) 
  return request({
    url,
    method:"delete",
    data
  })
}
//查列表
export function getList(params,type,moduleName,name){
  const url = returnUrl([moduleName,type,name]) 
  return request({
    url,params
  })
}
//查详细
export function getDetail(params,type,moduleName,name){
  const url = returnUrl([moduleName,type,name]) 
  return request({
    url,
    params
  })
}

//改
export function update(data,type,moduleName,name){
  const url = returnUrl([moduleName,type,name]) 
  return request({
    url,
    method:"put",
    data
  })
}
//特殊情况
export function customRequest(params,type,moduleName,name,method="get"){
  const url = returnUrl([moduleName,type,name]) 
  return request({
    url,
    method,
    params,
    data:params
  })
}
